package com.ppc.controller.worker;

import com.ppc.result.PageResult;
import com.ppc.result.Result;
import com.ppc.service.WorkerRequireService;
import com.ppc.vo.RequireBroadVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <<<<<<< HEAD
 *
 * @author jianKangS1 ======= 需求相关接口
 * @author Jeferry >>>>>>> origin/st
 * @date 2023/12/20
 */
@Slf4j
@RestController
@Api(tags = "工人需求接口")
public class WorkerRequireController {

  @Autowired
  private WorkerRequireService requireService;

  /**
   * <<<<<<< HEAD
   *
   * @param requireId
   * @param requireId 需求编号
   * @return {@link Result }<{@link RequireBroadVO }>
   * @return {@link Result}<{@link RequireBroadVO}> >>>>>>> origin/st
   * @description ======= 查看广泛需求信息
   */
  @GetMapping("/worker/requirement/query")
  @ApiOperation("查看广泛需求信息")
  public Result<RequireBroadVO> quertBroadInformation(Long requireId) {
    log.info("这是在查看需求编号为{}的信息", requireId);
    RequireBroadVO require = requireService.quertBroadInformation(requireId);
    return Result.success(require);
  }

  /**
   * <<<<<<< HEAD
   *
   * @param requireId 需求编号
   * @return {@link Result }
   * @return {@link Result} >>>>>>> origin/st
   * @description ======= 工人接受需求，将任务变成需求
   */
  @GetMapping("/worker/requirement/accepct")
  @ApiOperation("工人接受任务，将任务变成订单")
  public Result acceptRequire(Long requireId) {
    log.info("工人接受需求编号为{}的需求，将其变成任务", requireId);
    requireService.acceptRequire(requireId);
    return Result.success();
  }

  /**
   * <<<<<<< HEAD
   *
   * @param page
   * @param pageSize
   * @param page     页码
   * @param pageSize 页大小
   * @return {@link Result }<{@link PageResult }>
   * @return {@link Result}<{@link PageResult}> >>>>>>> origin/st
   * @description ======= 根据自己标签查找匹配的需求
   */
  @GetMapping("/worker/requirement/page")
  @ApiOperation("根据自己标签查找匹配的需求")
  public Result<PageResult> queryRequireByTags(Integer page, Integer pageSize) {
    log.info("工人根据自己标签去分页查询匹配的需求,{},{}", page, pageSize);
    PageResult p = requireService.queryRequireByTags(page, pageSize);
    return Result.success(p);
  }
}
